package com.usefullc.user.controller;

import com.usefullc.system.controller.BaseController;
import com.usefullc.user.service.WeixinService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author: Sampson
 * @date: 11/18/23 10:05 PM
 */
@RestController
@RequestMapping(path = "/user/wx/")
@Api(tags = "微信公众号控制类")
public class WeixinController extends BaseController {

    @Autowired
    private WeixinService weixinService;


    @ApiOperation("微信公众号服务器配置校验token")
    @RequestMapping(value = "/checkToken", method = RequestMethod.GET)
    public String checkToken(HttpServletRequest request) {
        return weixinService.checkToken(request);
    }


    @ApiOperation("处理微信服务器的消息转发")
    @RequestMapping(value = "checkToken", method = RequestMethod.POST)
    public String autoReply(HttpServletRequest request)  {
        String respXml = weixinService.autoReply(request);
        return respXml;
    }


}
